package com.dianping.cat.consumer.dependency.model.transform;
import com.dianping.cat.consumer.dependency.model.entity.Dependency;
import com.dianping.cat.consumer.dependency.model.entity.DependencyReport;
import com.dianping.cat.consumer.dependency.model.entity.Index;
import com.dianping.cat.consumer.dependency.model.entity.Segment;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/* 13 */     this.m_deferedJobs = new ArrayList();


/* 16 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/* 20 */     for (Runnable job : this.m_deferedJobs) {
/* 21 */       job.run();
    }
  }


  public boolean onDependency(final Segment parent, final Dependency dependency) {
/* 27 */     if (this.m_deferrable) {
/* 28 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 31 */               parent.addDependency(dependency);
            }
          });
    } else {
/* 35 */       parent.addDependency(dependency);
    }

/* 38 */     return true;
  }


  public boolean onIndex(final Segment parent, final Index index) {
/* 43 */     if (this.m_deferrable) {
/* 44 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 47 */               parent.addIndex(index);
            }
          });
    } else {
/* 51 */       parent.addIndex(index);
    }

/* 54 */     return true;
  }


  public boolean onSegment(final DependencyReport parent, final Segment segment) {
/* 59 */     if (this.m_deferrable) {
/* 60 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 63 */               parent.addSegment(segment);
            }
          });
    } else {
/* 67 */       parent.addSegment(segment);
    }

/* 70 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/dependency/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */